<?php
//首页控制器类
class IndexController extends AuthController{
	
	// 左侧菜单数组
	static private $menuConfig;
	
	// 初始化
	public function __init(){
		parent::__init();
		
		// 如果菜单数组为空
	    if (empty(self::$menuConfig)){
	    		// 加载menuConfig数组
	    		self::$menuConfig = include MODULE_CONFIG_PATH . 'menuConfig.php';
	    }
		
	}
	
    //首页
    public function index(){
        //显示视图
        $this->display();
    }
	
	public function welcome(){
		$userInfo = K('Admin')->where("aid='". session('aid') ."'")->find();
		$this->assign('userInfo', $userInfo);
		
		$this->assign('os_ver', php_uname());
		$this->assign('software', $_SERVER['SERVER_SOFTWARE']);
		$this->assign('php_ver', PHP_VERSION);
		$this->assign('server_ip', $_SERVER['SERVER_ADDR']);
		$this->assign('db_ver', mysql_get_client_info());
		
		$this->assign('login_time', time());
		$this->assign('login_ip', $_SERVER['REMOTE_ADDR']);
		
		$this->display();
	}
	
	public function left() {
		$dest = Q('get.dest', 'Home');
		$menuAry = self::$menuConfig[$dest];
		$this->assign('menuAry', $menuAry);
		
		switch ($dest){
			case 'Goods':
				$curSel = "商品列表";
				break;
			case 'Order':
				$curSel = "待发货订单";
				break;
			case 'Comment':
				$curSel = "评论列表";
				break;
			case 'User':
				$curSel = "用户列表";
				break;
			default:
				$curSel = "欢迎页面";
		}	
		
		$this->assign('curSel', $curSel);
		$this->display();
	}
	
	public function top() {
		$this->display();
	}
	
	public function bottom(){
		$dest = Q('get.dest', 'Home');
		switch ($dest){
			case 'Goods':
				$rightUrl = U('GoodsClass/Index');
				break;
			case 'Order':
				$rightUrl = U('Order/Delivering');
				break;
			case 'Comment':
				$rightUrl = U('Comment/Index');
				break;
			case 'User':
				$rightUrl = U('User/Index');
				break;
			default:
				$rightUrl = U('Index/Welcome');
		}		
		
		$this->assign('rightUrl', $rightUrl);
	    $this->display();
	}
}
